package com.modai.springcloud.entities;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

/**
 * @author ：modai
 * @date ：Created in 2020-12-17 22:44
 * @description：
 */
@RestController
@Slf4j
public class PaymentCotroller {
    @Value("${server.port}")
    private String serverPort;

    public static HashMap<Long, String> mySQL = new HashMap<>();
    static{
        mySQL.put(1L,"28a8c1e3bc2742d8848569891fb42181");
        mySQL.put(2L,"bba8c1e3bc2742d8848569891ac32182");
        mySQL.put(3L,"6ua8c1e3bc2742d8848569891xt92183");
    }

    @GetMapping("/payment/{id}")
    public CommonResult<Payment> pay(@PathVariable(value = "id") Long id) {
        String s = mySQL.get(id);
        log.info("当前服务端口号为{}，用户请求{}，获得结果：{}",serverPort,id,s);
        return new CommonResult<Payment>(200,"success"+serverPort,new Payment(id,s));
    }

}
